﻿Public Class LogIn

    Private Sub btnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalir.Click

        Global.System.Windows.Forms.Application.Exit()
    End Sub

    Private Sub btnIngresar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIngresar.Click

        If Not cmbLogin.SelectedItem Is Nothing Then
            ''Seteo la variable publica Csuario
            Dim EmpleadoDao As New daoEmpleado()
            Usuario = EmpleadoDao.TraeEmpleado(Convert.ToInt32(cmbLogin.SelectedValue))
            EmpleadoDao.Dispose()

            ''Seteo la variable publica Configuracion
            Dim ConfiguracionesDao As New daoConfiguraciones()
            Configuracion = ConfiguracionesDao.TraeConfiguraciones()
            ConfiguracionesDao.Dispose()

            Me.Hide()
            principal.ShowDialog()
            Me.Show()
        Else
            MessageBox.Show("Seleccione un Usuario de la lista, luego presione ingresar", "Atención!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End If
    End Sub

    Private Sub LogIn_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing

        'cancela el evento de salida valido para tecla escape o boton salir
        Dim rst As DialogResult

        rst = MessageBox.Show("¿Esta seguro que desea salir?", "Confirme", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

        If rst = Windows.Forms.DialogResult.No Then
            e.Cancel = True
        End If

    End Sub

    Private Sub LogIn_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Empleados As New List(Of clsEmpleado)
        Dim Dao_Empleado As New daoEmpleado
        Empleados = Dao_Empleado.TraeEmpleados()
        Dao_Empleado.Dispose()

        cmbLogin.DataSource = Empleados

        cmbLogin.DisplayMember = "Apellido"
        cmbLogin.ValueMember = "Emp_Id"



    End Sub
End Class
